package com.springboot.common.base;

import com.springboot.common.constant.ErrorCode;
import lombok.Data;

/**
 * 统一异常对象
 * @param <T>
 */
@Data
public class ResponseResult<T> extends BaseEntity {

    private String requestId = null;


    private String errorCode = ErrorCode.SUCCESS.getCode();

    private String errorMsg = ErrorCode.SUCCESS.getMessage();

    private T data;


    public ResponseResult(String errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public ResponseResult(String errorCode, String errorMsg, T data) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
        this.data = data;
    }

    public ResponseResult(T data) {
        this.data = data;
    }

    public boolean success(){
        return ErrorCode.SUCCESS.getCode().equals(this.errorCode);
    }

}
